package com.spring.hotel.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spring.hotel.common.JsonResponse;
import com.spring.hotel.entity.Comments;
import com.spring.hotel.entity.PageDTO;
import com.spring.hotel.mapper.CommentsMapper;
import org.springframework.stereotype.Service;

@Service
public class CommentsService extends ServiceImpl<CommentsMapper, Comments> {
    //分页展示
    public JsonResponse pageList(Comments comments, PageDTO pageDTO) {
        QueryWrapper<Comments> queryWrapper = new QueryWrapper<>();
        if (comments.getId() != null) {
            queryWrapper.lambda().like(Comments::getId, comments.getId());
        }
        Page<Comments> page = this.page(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), queryWrapper);
        return JsonResponse.success(page);
    }
}
